Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Discuss] Async use cases #1306

Closed
wants to merge 1 commit into from
Closed

Conversation

bendk
Copy link
Contributor

@bendk bendk commented Aug 4, 2022

I don't know if this document should be added to the docs section, the main reason I'm opening the PR is so we can discuss the use cases more.

@bendk bendk requested a review from a team as a code owner August 4, 2022 21:32
@bendk bendk requested review from badboy and removed request for a team August 4, 2022 21:32
@bendk bendk force-pushed the async-use-cases-doc branch from ba95ac5 to 392da0a Compare August 4, 2022 21:38

- Rust code making an async call into a CallbackInterface / Foreign code
making an async into Rust. I think this could be implemented by having
UniFFI generate something like the hand-written demo from #1252.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like a nice feature, but I'm not sure it's necessary. I think we could implement the Nimbus work with hand-written code. Maybe we could just start there and see if there's more demand before generating that code with UniFFI.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that hand-writing & using it that way seems sensible. That's how UniFFI was born to begin with.

UniFFI generate something like the hand-written demo from #1252.
- Handling CallbackInterface calls from a Rust-based thread. I'm not exactly sure how this would work, there's at least 2 options here:
- Handle everything on the foreign side. In the generate code we currently register a callback to invoke a CallbackInterface call. We might be able to update that code so that it schedules the call to run on the correct thread. But this assumes that it's safe to call that callback on the Rust thread. Is that true for all of our current languages? Are we okay with adding this requirement for future languages?
- Use a queue plus a waker. Push the CallbackInterface call to a queue, signal the foreign side (maybe writing a byte to a pipe or socket), then the foreign side would wake up and try to read from the queue. This seems more complicated than the first system, but might let us support more foreign languages.
Copy link
Contributor Author

@bendk bendk Aug 4, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feature seems necessary if we ever want to make a call from a Rust controlled (or C++ controlled) thread into JS. Maybe we want that for the Nimubs desktop work, but I'm not sure.

@bendk
Copy link
Contributor Author

bendk commented Mar 24, 2023

I think we have a good plan here, no need to keep this PR open longer.

@bendk bendk closed this Mar 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants